﻿<phone:PhoneApplicationPage
    x:Class="SampleApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:SampleApp"
    xmlns:controls="clr-namespace:SampleApp.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="20"
    Foreground="White"
	SupportedOrientations="Landscape"
	Orientation="LandscapeLeft">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Black">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

		<Border Grid.Row="0" Padding="10, 10, 10, 10" Background="Red" Margin="0, 0, 0, 10">
			<Grid>
				<TextBlock FontSize="32">
					<Run Text="LEGO MINDSTORMS EV3"/>
				</TextBlock>
				<StackPanel 
					Orientation="Horizontal" 
					HorizontalAlignment="Right" 
					VerticalAlignment="Center">
					<TextBlock>
						<Run Text="Connection Type: " />
						<Run Text="???" x:Name="ConnTypeRun" />
					</TextBlock>
				</StackPanel>
			</Grid>
		</Border>

		<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,00">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition />
			</Grid.RowDefinitions>
			<StackPanel
				Grid.Row="0"
				Orientation="Horizontal" 
				VerticalAlignment="Top">
				<local:MotorControl 
					Name="MotorA" 
					BrickInputPort="A"
					BrickOutputPort="A"
					SettingClicked="MotorSettingClicked"
					PlayClicked="MotorPlayClicked" />
				<local:MotorControl 
					Name="MotorB" 
					BrickInputPort="B"
					BrickOutputPort="B"
					SettingClicked="MotorSettingClicked"
					PlayClicked="MotorPlayClicked" />
				<local:MotorControl 
					Name="MotorC" 
					BrickInputPort="C"
					BrickOutputPort="C"
					SettingClicked="MotorSettingClicked"
					PlayClicked="MotorPlayClicked"/>
				<local:MotorControl 
					Name="MotorD" 
					BrickInputPort="D"
					BrickOutputPort="D"
					SettingClicked="MotorSettingClicked"
					PlayClicked="MotorPlayClicked"/>
			</StackPanel>
			<StackPanel
				Grid.Row="1"
				Orientation="Horizontal" 
				VerticalAlignment="Top">
				<local:SensorDataControl 
					Name="InputOne" 
					BrickInputPort="One"
					SettingClicked="SensorSettingClicked" />
				<local:SensorDataControl 
					Name="InputTwo" 
					BrickInputPort="Two"
					SettingClicked="SensorSettingClicked" />
				<local:SensorDataControl 
					Name="InputThree" 
					BrickInputPort="Three"
					SettingClicked="SensorSettingClicked" />
				<local:SensorDataControl 
					Name="InputFour" 
					BrickInputPort="Four"
					SettingClicked="SensorSettingClicked" />
			</StackPanel>
		</Grid>
		
		<controls:ConnectionControl
			Grid.Row="1" 
			Visibility="Collapsed"
			Name="ConnControl"
			ConnectToBrick="TryToConnect" />
		
		<controls:MotorSettingsControl
			Grid.Row="1" 
			Visibility="Collapsed"
			Name="MotorSettings" />

		<controls:SensorSettingsControl
			Grid.Row="1" 
			Visibility="Collapsed"
			Name="SensorSettings" />

		<controls:ProgressOverlayControl
			Grid.Row="0"
			Grid.RowSpan="2"
			Name="Overlay"
			Visibility="Collapsed" />
	</Grid>

	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar IsVisible="False">
			<shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem Text="Play Tone" Click="PlayToneClick" />
			</shell:ApplicationBar.MenuItems>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>
	
</phone:PhoneApplicationPage>